package moltencore.network.serverlobby;

import moltencore.config.Config;
import moltencore.player.PlayerList;
import moltencore.player.Player;
import moltencore.network.serverlobby.strategy.GameListRequestStrategy;
import moltencore.network.serverlobby.strategy.LogoutStrategy;
import moltencore.network.serverlobby.strategy.LoginStrategy;
import moltencore.network.serverlobby.strategy.CreateGameStrategy;

public class StrategyFactory {
	private PlayerList<Player> playerList;
	private GameList gameList;

	private LoginStrategy login;
	private LogoutStrategy logout;
	private CreateGameStrategy createGame;
	private GameListRequestStrategy gameListRequest;

	public StrategyFactory(PlayerList<Player> playerList, GameList gameList) {
		this.playerList = playerList;
		this.gameList = gameList;
	}

	public LoginStrategy getLoginStrategy() {
		if(login != null) {
			return login;
		}
		login = new LoginStrategy(playerList);
		return login;
	}

	public LogoutStrategy getLogoutStrategy() {
		if(logout != null) {
			return logout;
		}
		logout = new LogoutStrategy(playerList);
		return logout;
	}

	public CreateGameStrategy getCreateGameStrategy() {
		if(createGame != null) {
			return createGame;
		}
		createGame = new CreateGameStrategy(gameList);
		return createGame;
	}

	public GameListRequestStrategy getGameListRequestStrategy(){
		if (gameListRequest == null){
			gameListRequest = new GameListRequestStrategy(gameList);
		}
		return gameListRequest;
	}
}
